<%@ page language="java" contentType="text/html;charset=utf-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
<!DOCTYPE html>
<!--[if IE 8]> <html lang="en" class="ie8 no-js"> <![endif]-->
<!--[if IE 9]> <html lang="en" class="ie9 no-js"> <![endif]-->
<!--[if !IE]><!-->
<html lang="en" class="no-js">
<!--<![endif]-->
<head>
<jsp:include page="../common/common.jsp" />
</head>
<body class="page-header-fixed">
	<jsp:include page="../common/header.jsp" />

	<div class="clearfix"></div>
	<div class="page-container">
		<div class="page-sidebar-wrapper"><jsp:include
				page="../common/menu.jsp" /></div>
		<div class="page-content-wrapper">
			<div class="page-content">
				<div class="row">
					<div class="col-md-12">
						<form class="form-horizontal form-row-seperated" id="form"
							method="post" action="${path}/chatContent/save">
							<div class="portlet box purple">
								<div class="portlet-title">
									<div class="caption">
										<i class="fa fa-shopping-cart"></i>基础数据详细内容
									</div>
									<div class="actions btn-set">
										<a href="javascript:history.go(-1);" class="btn default"><i
											class="fa fa-angle-left"></i> 返回</a>
										<button type="button" onclick="save()" class="btn blue">
											<i class="fa fa-check"></i> 保存
										</button>
									</div>
								</div>
								<div class="portlet-body">
									<div class="tabbable">
										<div class="tab-content no-space">
											<div class="tab-pane active" id="tab_general">
												<div class="form-body">

													<div class="form-group">
														<label class="col-md-2 control-label">主题:<span
															class="required">*</span></label>
														<div class="col-md-3">
															<select name="chatType" id="chatType" class="form-control"  onchange="opende(this)"
																>
																	 <option value="">请选择</option>
															 <!--  <c:forEach items="${confdata}" var="c">
                                                   					 <option value="${c.id}">${c.value0}</option>
                                              					  </c:forEach> -->  
                                              					  	 <option value="1">文字</option>
                                              					  	 	 <option value="2">图片</option>
															</select>
														</div>
													</div>
  									
													<div class="form-group"  id="wz">
														<label class="col-md-2 control-label">文字: <span
															class="required"> </span>
														</label>

														<div class="col-md-5">
															<input type="text" id="chatContent" name="chatContent"
																class="form-control measure-input"
																value="${data.chatContent}" />
														</div>
														<div class="col-md-5">
															<!--                                                         &nbsp;可输入<b><span id="title_len">32</span></b> 个字符 -->
														</div>
													</div>
													
													<div class="form-group" id="tp"  style="display: none;">
														<label class="col-md-2 control-label">图片:</label>
														<div class="col-md-8">
															<div class="fileinput fileinput-new"
																data-provides="fileinput">
																<div class="fileinput-new thumbnail"
																	style="width: 315px; height: 180px;">
																	<img src="${data.chatContent}">
																</div>
																<div
																	class="fileinput-preview fileinput-exists thumbnail"
																	style="max-width: 315px; max-height: 180px;"></div>
																<div>
																	<span class="btn default btn-file"> <span
																		class="fileinput-new"> 选择图片 </span> <span
																		class="fileinput-exists"> 修改图片 </span> <input
																		type="file" id="file" name="file" />
																	</span> <a href="#" class="btn default fileinput-exists"
																		data-dismiss="fileinput"> 移除图片 </a>
																</div>
															</div>
														</div>
													</div>
												     
												</div>
											</div>
										</div>
									</div>
								</div>

								<div class="portlet-title">
									<div class="actions btn-set">
										<a href="javascript:history.go(-1);" class="btn default"><i
											class="fa fa-angle-left"></i> 返回</a>
										<button type="button" onclick="save()" class="btn blue">
											<i class="fa fa-check"></i> 保存
										</button>
									</div>
								</div>
							</div>
							<input type="hidden" id="id" name="id" value="${data.id}">
							 
						</form>
					</div>
				</div>
			</div>
		</div>
	</div>
	<jsp:include page="../common/footer.jsp" />
	<script type="text/javascript" src="${path}/assets/plugins/bootstrap-fileinput/bootstrap-fileinput.js"></script>
	<script type="text/javascript" src="${path}/assets/plugins/jquery-inputmask/jquery.inputmask.bundle.min.js"></script>
<script type="text/javascript" src="${path}/assets/plugins/jquery.input-ip-address-control-1.0.min.js"></script>
<script type="text/javascript" src="${path}/assets/scripts/biz/ajaxfileupload.js"></script>
	<script>
	function save(){
		if ($("#file").val() != null && $("#file").val() != "") {
			$.ajaxFileUpload({
				url : '${path}/conf/upload',
				async : false,
				secureuri : false,
				fileElementId : 'file',
				dataType : 'json',
				success : function(data, status) {
					if (data.statusCode == 200) {
						$("#chatContent").val(data.uri);
						$("#form").submit();
						return;
					}else{
						layer.alert("糟糕！ 图片上传失败...", {
			  		        icon: 2,
			  		        offset: 'middle',
			  		        time: 3000, 
			  		        skin: 'layui-layer-lan'
			  		    });
					}
				}
			});
		}else{
			$("#form").submit();
		}
	}
	
		
		
	    function opende(em){
		
		if($(em).val()==1){
			$("#wz").show();
			$("#tp").hide();
		}else if($(em).val()==2){
			$("#wz").hide();
			$("#tp").show();
		}
	}
	    
	 
	</script>
</body>
</html>